###
### DECENT LIVING STANDARDS MAPPING 
### 

rm(list=ls())

##
## PACKAGES --------------------------------------------------------------------
## 

library(tidyverse)
library(ggcorrplot)

##
## LOAD DATA--------------------------------------------------------------------
##


load("Complete DLS data file_regional level.RData")

##
## PROCESSING AND SELECTING RELEVANT DATA --------------------------------------
## 

dim <- dls_region %>% select(dim1_housing_region, dim2_thermal_region, dim3_nutrition_region, dim4_foodprep_region, 
                      dim5_water_region, dim6_sanitation_region, dim7_health_region,
                      dim8_education_region, dim9_socialconnect_region, dim10_physicalconnect_region)

dim1 <- dim %>% drop_na()

dim1 <- dim1 %>% 
  rename("Housing"="dim1_housing_region",
         "Thermal"="dim2_thermal_region",
         "Nutrition"="dim3_nutrition_region",
         "Food preparation"="dim4_foodprep_region",
         "Water"="dim5_water_region",
         "Sanitation"="dim6_sanitation_region",
         "Health care"="dim7_health_region",
         "Education"="dim8_education_region",
         "Social connected"="dim9_socialconnect_region",
         "Physical connected"="dim10_physicalconnect_region")

##
## CORRELATION MATRIX AND FIGURE -----------------------------------------------
## 

dim_corr <- round(cor(dim1), 3)
#head(dim_corr)

g1 <- ggcorrplot(dim_corr, hc.order = TRUE, type = "lower", outline.color = "white", lab = TRUE,
           colors = c("#4755d1", "white", "red"),title="",lab_size = 3, tl.cex=10) #method = "circle"
g1 <- g1 + ggtitle("")

ggsave(g1, filename = "supplementary figure s5a.png", width = 6, height=5)
save(g1, file= "supplementary figure s5a.RData")
